﻿using CommonType;
using MediatR;
using S_Incident.Domains.EventHandling;
using S_Incident.Infrasturctre.DapperInterface;
using S_Incident.Read.API.Application.Commands;

namespace S_Incident.Read.API.Application.CommandsHanders
{
    public class EventDispositionBackfillCommandHanderHanders : IRequestHandler<EventDispositionBackfillCommand, ApiResule<EventDisposition>>
    {
        private readonly IDapperEventDispositionBackfillRepository _repository;

        public EventDispositionBackfillCommandHanderHanders(IDapperEventDispositionBackfillRepository repository)
        {
            _repository = repository;
        }

        /// <summary>
        /// 流程管理列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ApiResule<EventDisposition>> Handle(EventDispositionBackfillCommand request, CancellationToken cancellationToken)
        {
            string sql = "SELECT * FROM EventDisposition WHERE Id = @Id";

            var result = await _repository.GetOne(request.id, sql);

            return new ApiResule<EventDisposition>
            {
                Code = 200,
                Msg = "成功",
                Result = result
            };
        }
    }
}
